package com.breeze.components.socket.memory;

import com.breeze.components.socket.WebSocketManager;
import com.breeze.components.socket.WebSocketProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 内存websocket配置
 *
 * @author breeze
 */
@ConditionalOnProperty(prefix = "breeze.websocket", name = "isCluster", havingValue = "false")
@AutoConfiguration
@EnableConfigurationProperties(WebSocketProperties.class)
public class MemoryWebSocketConfig {

  @Bean(WebSocketManager.WEBSOCKET_MANAGER_NAME)
  @ConditionalOnMissingBean(name = WebSocketManager.WEBSOCKET_MANAGER_NAME)
  public WebSocketManager webSocketManager() {
    return new MemWebSocketManager();
  }
}
